package com.shensi.api.admin.client.system;

import com.shensi.api.admin.client.fallback.system.SysConfigClientFallBack;
import com.shensi.api.admin.domian.system.SysConfig;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.page.TableDataInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author: budian
 * @since: 2023/11/30
 */
@FeignClient(
        value = CloudConstant.ADMIN_SERVER,
        fallbackFactory = SysConfigClientFallBack.class)
@Component
public interface SysConfigClient {

    /**
     * 获取参数配置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(@SpringQueryMap SysConfig config);


    @GetMapping("/export")
    public AjaxResult export(@SpringQueryMap SysConfig config);

    /**
     * 根据参数编号获取详细信息
     */
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId);

    /**
     * 根据参数键名查询参数值
     */
    @GetMapping(value = "/configKey/{configKey}")
    public AjaxResult getConfigKey(@PathVariable("configKey") String configKey);

    /**
     * 新增参数配置
     */
    @PostMapping
    public AjaxResult add(@RequestBody SysConfig config);

    /**
     * 修改参数配置
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SysConfig config);

    /**
     * 删除参数配置
     */
    @DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable("configIds") Long[] configIds);

    /**
     * 清空缓存
     */
    @DeleteMapping("/clearCache")
    public AjaxResult clearCache();
}
